<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login_Model extends CI_Model {

	function __construct()
	{
		parent::__construct();
	}

	function Conferir($str,$campo)
	{
		$this->db->where($campo, $str);
		$query = $this->db->get('lm_usuarios');
		if($query->num_rows()) return FALSE;
		return TRUE;
	}

	function Logar()
	{
		$this->db->select('id,senha');
		$query = $this->db->get_where('lm_usuarios', array('nome' => $this->input->post('nome')));
		$dados = '';
		$dados['id'] = 0;
		$dados['senha'] = 0;
		foreach ($query->result_array() as $row => $valor)
			foreach ($valor as $key => $value)
				$dados[$key] = $value;
		if($dados['senha'] == $this->input->post('senha')) return $dados['id'];
		return FALSE;
	}
	
	function DadoUsuario($campos,$id)
	{
		$this->db->select($campos);
		$query = $this->db->get_where('lm_usuarios', array('id' => $id));
		$result = '';
		foreach ($query->result_array() as $row => $valor)
			foreach ($valor as $key => $value)
			$result[$key] = $value;
		return $result;
	}
}